<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="crm.model.Customer"%>
<%@page import="crm.control.CustomerControl"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.util.ToPinyin"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>customer_update</title>
	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
			Customer customer = new Customer();
			int id = Integer.parseInt(request.getParameter("id"));
			//System.out.println(id);
           customer = CustomerControl.getCustomerById(id);
			
			String name = ParamUtil.getString(request, "name", null);
			String namepy = ToPinyin.getPinYin(name);
			customer.setName(name);
            customer.setNamepy(namepy);  
			String address = ParamUtil.getString(request, "address",null);
			customer.setAddress(address);

			String phone = ParamUtil.getString(request, "phone", null);
			customer.setPhone(phone);

			

			int area_id = ParamUtil.getInt(request, "area_id", 0);
			customer.setArea_id(area_id);

			String type = ParamUtil.getString(request, "type", null);
			customer.setType(type);

			String origin = ParamUtil.getString(request, "origin", null);
			customer.setOrigin(origin);

			String crete_time = ParamUtil.getString(request, "crete_time", null);
			customer.setCrete_time(crete_time);

			String business = ParamUtil.getString(request,"business", null);
			customer.setBusiness(business);
			
			
			

			if (CustomerControl.updateCustomer(customer)){
		%>
		<script type="text/javascript">
if (window.confirm("修改成功！"))
	window.top.location.href = "customer.jsp";
	else
    window.top.location.href = "customer.jsp";
</script>
		<%
			} else {
		%>
		<script type="text/javascript">
if (window.confirm("修改失败！"))
	window.top.location.href = "customer.jsp";
	else
    window.top.location.href = "customer.jsp";
</script>
		<%
			}
		%>
	</body>
</html>